// import { createApp } from 'vue'
// import App from '../App.vue'
// import './router/guard'
// import '../assets/styles/index.scss'
// import 'normalize.css/normalize.css'
// import { createPinia } from 'pinia'
// import { i18n } from '../locales'
// import VueClickAway from 'vue3-click-away'
// import lazyPlugin from 'vue3-lazy'
// import { registerSvgIcon } from '../icons'
// import { registerObSkeleton } from '../components/LoadingSkeleton'
// import 'prismjs/themes/prism.css'
// import 'prismjs'
// import ElementPlus from 'element-plus'
// import 'element-plus/dist/index.css'
// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
// import infiniteScroll from 'vue3-infinite-scroll-better'
// import v3ImgPreview from 'v3-img-preview'
// import 'mavon-editor/dist/css/index.css'
// import api from '../api/api'
// import { defineNuxtPlugin, useNuxtApp } from 'nuxt/app'
// import { setupStore } from "../stores"

// const pinia = createPinia()
// pinia.use(piniaPluginPersistedstate)

// export default defineNuxtPlugin(() => {
//   const nuxtApp  = useNuxtApp();
//   const app = nuxtApp.vueApp;
//   setupStore(app); 
//   setupLazy(app);
// })

// export const app = createApp(App)
//   .use(router)
//   .use(pinia)
//   .use(i18n)
//   .use(VueClickAway)
//   .use(infiniteScroll)
//   .use(v3ImgPreview, {})
//   .use(lazyPlugin, {
//     loading: require('@/assets/default-cover.jpg'),
//     error: require('@/assets/default-cover.jpg')
//   })
//   .use(ElementPlus)

// registerSvgIcon(app)
// registerObSkeleton(app)


import { defineNuxtPlugin } from 'nuxt/app';  
import { createPinia } from 'pinia';  
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';  
import VueClickAway from 'vue3-click-away';  
import lazyPlugin from 'vue3-lazy';  
import infiniteScroll from 'vue3-infinite-scroll-better';  
import v3ImgPreview from 'v3-img-preview';  
import ElementPlus from 'element-plus';  
import 'element-plus/dist/index.css';  
import 'prismjs/themes/prism.css';  
import 'prismjs';  
import 'normalize.css/normalize.css';  
import '@/styles/index.scss';  
import { registerSvgIcon } from '../icons';  
import { registerObSkeleton } from '../components/LoadingSkeleton';  
import { i18n } from '../locales';  


export default defineNuxtPlugin((nuxtApp) => {  
  // 初始化 Pinia  
  const pinia = createPinia();  
  pinia.use(piniaPluginPersistedstate);  
  
  nuxtApp.vueApp.use(pinia);  
  
  // 注册全局插件  
  nuxtApp.vueApp.use(VueClickAway);  
  nuxtApp.vueApp.use(infiniteScroll);  
  nuxtApp.vueApp.use(v3ImgPreview, {});  
  nuxtApp.vueApp.use(lazyPlugin, {  
    loading: require('@/assets/default-cover.jpg'),  
    error: require('@/assets/default-cover.jpg')  
  });  
  nuxtApp.vueApp.use(ElementPlus);  
  
  // 注册全局组件或指令  
  registerSvgIcon(nuxtApp.vueApp);  
  registerObSkeleton(nuxtApp.vueApp);  
  
  // Nuxt.js 自动处理路由和挂载点  
  // 不需要 app.mount('#app')  
  
  // 国际化（如果你使用的是 nuxt-i18n 模块，则按该模块的方式配置）  
  // 如果不是，你可能需要安装并配置 nuxt-i18n 或类似的库  
  nuxtApp.vueApp.config.globalProperties.$i18n = i18n;  
});